#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5+5;
int n,l,a[N],b[N],ans;
void dfs(int x,int xora,int xorb)
{
	if(x>n)
	{
		if(xora<l) ans = max(ans,xorb);
		return;
	}
	dfs(x+1,xora,xorb),dfs(x+1,xora^a[x],xorb^b[x]);
}
signed main()
{
	freopen("lock.in","r",stdin);
	freopen("lock.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>l;
	for(int i = 1;i<=n;i++)
		cin>>a[i];
	for(int i = 1;i<=n;i++)
		cin>>b[i];
	dfs(1,0,0);
	cout<<ans;
	return 0;
}

